package cn.xabad.server.thea.test

import cn.xabad.server.thea.controller.IndexController
import cn.xabad.server.thea.ext.onlyDay
import cn.xabad.server.thea.http.AppLogService
import feign.Feign
import feign.gson.GsonDecoder
import feign.gson.GsonEncoder
import org.apache.poi.ss.usermodel.CellType
import org.apache.poi.xssf.usermodel.XSSFWorkbook
import org.joda.time.DateTime
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.FileInputStream
import java.io.FileOutputStream
import java.text.DecimalFormat

fun main3(args: Array<String>) {
    val df = DecimalFormat("0")
    val file = "/Users/xueyong/Downloads/工作簿1.xlsx"
    val fileInputStream = FileInputStream(file)
    val workbook = XSSFWorkbook(fileInputStream)
    val sheet = workbook.getSheetAt(0)
    println( sheet.physicalNumberOfRows)
    IntRange(0, sheet.physicalNumberOfRows).forEach {
        val row = sheet.getRow(it)
        val idCell = row.getCell(1)
        val timeCell = row.getCell(3)
        idCell.setCellValue(DateTime(idCell.stringCellValue).toString("yyyy-MM-dd HH:mm:ss"))
        timeCell.setCellValue(DateTime(timeCell.stringCellValue).toString("yyyy-MM-dd HH:mm:ss"))
    }
    fileInputStream.close()
    val fileOut = FileOutputStream(file)
    workbook.write(fileOut)
    fileOut.flush()
    fileOut.close()
}